package com.gxa.controller.zls;

import com.gxa.common.R;
import com.gxa.pojo.*;
import com.gxa.service.zls.SystemService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Controller
@Api(value = "设置",tags = "设置(高级设置)数据接口API")
@RequestMapping("/Advancedsetting")
public class AdvancedsettingController {

    @Autowired
    private SystemService systemService;


    //用户登录
    @RequestMapping(value = "/userLogin",method = RequestMethod.POST)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "username",value = "用户名",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "password",value = "用户密码",paramType = "query",dataType = "String",required = true),
    })
    @ResponseBody
    public R userLogin(@RequestBody Map map){
        String username = (String) map.get("username");
        String password = (String) map.get("password");
        R r = systemService.userLogin(username,password);
        return r;
    }

    //修改密码
    @RequestMapping(value = "/changePassword",method = RequestMethod.POST)
    @ResponseBody
    public R updatePwd(@RequestBody Map map){
        R r = systemService.updatePwd(map);
        return r;
    }

    //修改系统参数
    @RequestMapping(value = "/updateSystemParam",method = RequestMethod.POST)
    @ApiOperation(value = "修改系统参数接口",notes = "修改系统参数",httpMethod = "POST", response = String.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R updateSystem_param(@RequestBody @ApiParam(name = "system_param",value = "系统参数") System_Param system_param){
        R r = systemService.updateSystemParam(system_param);
        return r;
    }

    //查询系统参数
    @RequestMapping(value = "/querySystemParam",method = RequestMethod.GET)
    @ApiOperation(value = "查询系统参数接口",notes = "查询系统参数",httpMethod = "get", response = String.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R querySystemParam(){
        R r = systemService.querySystem();
        return r;
    }

    //查询日志
    @RequestMapping(value = "/queryLog",method = RequestMethod.POST)
    @ApiOperation(value = "查询操作日志接口",notes = "操作日志查询",httpMethod = "get", response = String.class)
    @ApiImplicitParams({
            @ApiImplicitParam(defaultValue = "1",name = "page",value = "当前页码",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(defaultValue = "50",name = "limit",value = "当前条数",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "beginTime",value = "查询起始日期",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "endTime",value = "查询结束日期",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "name",value = "搜索输入用户名",paramType = "query",dataType = "String",required = false)
    })
    @ResponseBody
    public R queryLog(@RequestBody Map map){
        R r = systemService.queryLog(map);
        return r;
    }

    //新增同事
    @RequestMapping(value = "/addUser",method = RequestMethod.POST)
    @ApiOperation(value = "新增用户接口",notes = "新增同事",httpMethod = "post", response = String.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R addUser(@RequestBody @ApiParam(name = "user",value = "新增同事")User user){
        R r = systemService.addUser(user);
        return r;
    }

    //查询用户
    @RequestMapping(value = "/queryUser",method = RequestMethod.GET)
    @ApiOperation(value = "权限设置显示",notes = "查询用户",httpMethod = "get", response = String.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R queryUser(){
        R r = systemService.queryUser();
        return r;
    }










}
